<?php
/* 
 * Copyright (c) 2018-2021   All rights reserved.
 * 
 * 创建时间：2021-06-23 08:42
 *
 * 项目：rm  -  $  - zip.php
 *
 * 作者：liwei 
 */


?>

<style>
    .files-box {font-size:12px;background: #666;color: #fff;padding-top: 10px;padding-bottom:10px}
    #zip_form .card-header {font-size: 14px;color:#555555}
</style>

<div class="page page-admin">
    <?php Lev::navbarAdmin();?>

    <div class="page-content">
        <div class="page-content-inner" style="max-width: 900px !important;">

            <form id="zip_form" action="<?=reset($btns)?>" method="post">
                <input type="hidden" name="_csrf" value="<?=Lev::$app['_csrf']?>">
            <div class="alert alert-info" style="margin-top: 20px">
            <ol style="font-size:12px">
<!--                <li>前置版：必须依赖于其它独立版运行，模块中无Lev基础包</li>-->
<!--                <li>独立版：可以独自运行，自动在模块中加Lev基础包</li>-->
<!--                <li>独立版(即：内含Lev基础包的)，不可以压缩为前置版。主要用途保证开发环境中仅存在一个Lev包即可</li>-->
<!--                <li>子模块不可以压缩为独立版</li>-->
                <li>默认在压缩前自动导出模块信息和设置项，不导出表数据</li>
                <li><?=$mudInfo['version']?> 历史版本：<?php echo implode(' | ', \modules\levmodules\helpers\zipHelper::versions($mudInfo['identifier']))?></li>
            </ol>
            </div>
            <div class="flex-box" style="justify-content: right">
                <?php foreach ($btns as $name => $link):?>
                    <label class="button button-fill scale7 wdmin wd30 doSubmitBtn color-<?=empty($ckd) ? ($ckd = 'red') : 'gray' ?>" href="<?=$link?>">
                        <?=$name?>
                    </label>
                <?php endforeach;?>
                <input type="submit" name="dosubmit" class="button button-fill color-lightblue animated heartBeat wdmin wd30" value=" 确定提交 ">
            </div>

                <div class="card-header">
                    <div class="item-after"><div class="hint-block">版本更新内容</div></div>
                    <div class="item-input">
                        <select name="LevVersion" style="max-width: 120px">
                            <option value="">Lev版本支持(默认最低)</option>
                            <?php if (!empty($LevVersions)): krsort($LevVersions); foreach ($LevVersions as $v):?>
                                <option value="<?=$v?>" <?=$LevVersion == $v ?'selected':''?>><?=$v?></option>
                            <?php endforeach; endif;?>
                        </select>
                    </div>
                    <div class="item-input">
                        <?php if (empty($uploadZipStore)):?>
                        <select name="ftpServer" style="max-width: 120px">
                            <option value="">不上传</option>
                            <?php foreach ($ftpServers as $v):?>
                                <option value="<?=$v['id']?>">上传到【<?=$v['descs'],$v['serverDomain']?>】</option>
                            <?php endforeach;?>
                        </select>
                        <?php else:?>
                        <b class="red">上传到模块商店</b>
                        <?php endif;?>
                    </div>
                </div>
                <inpt class="item-input">
                    <textarea class="form-control resizable" name="updateDesc" style="width: 100%"><?=$updateDesc?></textarea>
                </inpt>

                <div class="card-header">
                    <label class="allZipFilesCkTLabel color-gray"><input class="ckT" type="checkbox">压缩预览</label>
                    <tips>勾选后不压缩</tips><?=$totals<5000?'':'<tips>文件数量过多仅显示文件夹</tips>'?>
                    <a class="button-fill button color-black showFileToggleBtn inblk scale8">查看</a>
                </div>
                <ol class="files-box hiddenx showFileToggle allZipFiles">
                    <?php foreach ($globsIden as $df => $v): if ($totals <5000 || strpos(substr($df, -8), '.') === false):?>
                        <li><label><input type="checkbox" name="unfiles[]" <?=isset($unFiles[$df])?'checked':'',(isset($dunFiles[$df]) ?' disabled':'')?> value="<?=$df?>"><?=$df?></label></li>
                    <?php endif;endforeach;?>
                </ol>

                <div class="card-header">
                    <label><input class="ckT" type="checkbox" checked>gbk支持、子模块、安装文件等常用选择性压缩</label>
                    <a class="button-fill button color-black showFileToggleBtn inblk scale8">查看</a>
                </div>
                <ol class="files-box hiddenx showFileToggle">
                    <?php foreach ($childglobs as $df => $v):?>
                        <li><label><input type="checkbox" name="unfiles[]" <?=isset($unFiles[$df])?'checked':''?> value="<?=$df?>"><?=$df?></label></li>
                    <?php endforeach;?>
                </ol>

                <div class="card-header">
                    <label class="disabled"><input class="ckT disabled" type="checkbox" checked disabled>固定不压缩</label>
                    <tips>【注意】强制压缩文件路径中含有【/_generates/】的文件</tips>
                    <a class="button-fill button color-black showFileToggleBtn inblk scale8">查看</a>
                </div>
                <ol class="files-box hiddenx showFileToggle">
                    <?php foreach ($unglobs as $df => $v):?>
                        <li><label><?=$df?></label></li>
                    <?php endforeach;?>
                </ol>

                <div class="card-header">
                    <label><input class="ckT font12" type="checkbox" checked>选择不需要压缩的文件(<tips>独立版有效，前置版忽略</tips>)</label>
                    <div>
                    <label class="shake animated">
                        <select name="replaceinlev" class="wd150 font12">
                            <option value="">不添加Access文件头（默认无需添加）</option>
                            <option value="IN_DISCUZ" <?=isset($unFiles['add IN_DISCUZ'])?'selected':''?>>
                                add IN_DISCUZ：为php文件添加 !defined('IN_DISCUZ') && exit('Access Denied'); INLEV 替换成 IN_DISCUZ
                            </option>
                            <option value="INLEV" <?=isset($unFiles['add INLEV'])?'selected':''?>>
                                add INLEV：为php文件添加 !defined('INLEV') && exit('Access Denied');
                            </option>
                        </select>
                    </label>
                    </div>
                    <tips>不常用静态文件，勾选后不压缩</tips>
                </div>
                <ol class="files-box">
                    <?php foreach ($globs as $df => $v):?>
                        <li><label><input type="checkbox" name="unfiles[]" <?=isset($unFiles[$df])?'checked':''?> value="<?=$df?>"><?=$df?></label></li>
                    <?php endforeach;?>
                </ol>
            </form>
        </div>
    </div>
</div>

<script>
(function () {
    'use strict';

    jQuery(function () {
        Levme.onClick('.showFileToggleBtn', function () {
            var n = jQuery(this).index('.showFileToggleBtn');console.log(n);
            jQuery('.showFileToggle').eq(n).hasClass('hiddenx')
                ? jQuery('.showFileToggle').eq(n).removeClass('hiddenx')
                : jQuery('.showFileToggle').eq(n).addClass('hiddenx');
        });

        Levme.onClick('.ckT', function () {
            checkedToggle(this, jQuery('.files-box').eq(jQuery(this).index('.ckT')).find('input'));
        });

        Levme.onClick('.doSubmitBtn', function () {
            jQuery('.doSubmitBtn.color-red').removeClass('color-red');
            jQuery(this).addClass('color-red');
            jQuery('#zip_form').attr('action', jQuery(this).attr('href'));
        });

        Levme.onClick('form input[type="submit"]', function () {
            showIconLoader();
            levtoast('正在执行，请不要关闭页面，耐心等待...');
        });

        jQuery('.allZipFiles input[type="checkbox"]:checked').length >0 &&
            jQuery('.allZipFilesCkTLabel').css('color','#007aff');
    });

})();
</script>






